package com.burstly.lib.component.networkcomponent.burstly.html;

import android.content.Context;
import android.webkit.WebSettings;
import android.webkit.WebView;
import com.burstly.lib.component.networkcomponent.burstly.html.mraid.MraidView;
import com.burstly.lib.component.networkcomponent.burstly.html.ormma.OrmmaView;
import com.burstly.lib.component.networkcomponent.burstly.html.rewards.RewardsView;
import com.burstly.lib.network.beans.DestinationType;
import com.burstly.lib.network.beans.ResponseBean;
import com.burstly.lib.network.beans.ResponseBean.Color;
import com.burstly.lib.network.beans.ResponseBean.ResponseData;
import com.burstly.lib.util.LoggerExt;
import com.burstly.lib.util.UiSafeWebView;
import com.burstly.lib.util.Utils;

public class WebViewFactory
{
  private static final LoggerExt LOG = LoggerExt.getInstance();
  private static final String TAG = WebViewFactory.class.getSimpleName();
  private final Context mContext;
  private boolean mCreateForFullscreen;
  private final ResponseBean mFullResponse;
  private final ResponseBean.ResponseData mRdata;
  private IFactoryCallback mVisitor;
  private UiSafeWebView mWebView;

  public WebViewFactory(Context paramContext, ResponseBean.ResponseData paramResponseData, ResponseBean paramResponseBean)
  {
    this.mContext = paramContext;
    this.mRdata = paramResponseData;
    this.mFullResponse = paramResponseBean;
  }

  private void createDefault()
  {
    UiSafeWebView localUiSafeWebView = new UiSafeWebView(this.mContext);
    if (this.mVisitor != null)
      this.mVisitor.defaultViewCreated(localUiSafeWebView);
    this.mWebView = localUiSafeWebView;
  }

  private void createImplementation()
  {
    if (Utils.isOrmma(this.mRdata.getAdType()))
    {
      createOrmma();
      return;
    }
    if (Utils.isMraid(this.mRdata.getAdType()))
    {
      createMraid();
      return;
    }
    if (isRewards())
    {
      createRewards();
      return;
    }
    createDefault();
  }

  private void createMraid()
  {
    MraidView localMraidView = new MraidView(this.mContext);
    Integer localInteger = this.mRdata.getSkipButtonActivationTime();
    if (localInteger != null)
      localMraidView.setCloseButtonShowDelay(1000 * localInteger.intValue());
    if (this.mVisitor != null)
      this.mVisitor.mraidViewCreated(localMraidView);
    this.mWebView = localMraidView;
  }

  private void createOrmma()
  {
    this.mWebView = new OrmmaView(this.mContext);
    if (this.mVisitor != null)
      this.mVisitor.ormmaViewCreated((OrmmaView)this.mWebView);
  }

  private void createRewards()
  {
    this.mWebView = new RewardsView(this.mContext);
    if (this.mVisitor != null)
      this.mVisitor.rewardsViewCreated((RewardsView)this.mWebView);
  }

  private void doCreate(IFactoryCallback paramIFactoryCallback)
  {
    this.mVisitor = paramIFactoryCallback;
    createImplementation();
    setBackgroundColor(this.mWebView);
    this.mWebView.setClickable(true);
    this.mWebView.setInterstitial(this.mCreateForFullscreen);
    this.mWebView.setScrollContainer(false);
    this.mWebView.setVerticalScrollBarEnabled(false);
    this.mWebView.setHorizontalScrollBarEnabled(false);
    this.mWebView.setInitialScale(1);
    WebSettings localWebSettings = this.mWebView.getSettings();
    localWebSettings.setSavePassword(false);
    localWebSettings.setSaveFormData(false);
    localWebSettings.setJavaScriptEnabled(true);
    localWebSettings.setPluginsEnabled(true);
    localWebSettings.setSupportZoom(false);
    localWebSettings.setBuiltInZoomControls(false);
    localWebSettings.setLoadWithOverviewMode(true);
    localWebSettings.setUseWideViewPort(true);
    this.mVisitor = null;
  }

  private boolean isRewards()
  {
    boolean bool = Utils.isRewards(this.mRdata.getDataType());
    if ((!bool) && (this.mCreateForFullscreen))
    {
      Integer localInteger = this.mRdata.getDestType();
      if ((DestinationType.OfferCustom.getValue().equals(localInteger)) || (DestinationType.OfferDownload.getValue().equals(localInteger)) || (DestinationType.OfferFlipbook.getValue().equals(localInteger)) || (DestinationType.OfferPromotion.getValue().equals(localInteger)) || (DestinationType.OfferShare.getValue().equals(localInteger)) || (DestinationType.OfferWatch.getValue().equals(localInteger)))
        bool = true;
    }
    else
    {
      return bool;
    }
    return false;
  }

  private void setBackgroundColor(WebView paramWebView)
  {
    ResponseBean.Color localColor = this.mFullResponse.getColor();
    if (localColor != null)
    {
      String str = (String)localColor.get("bg");
      Integer localInteger = Utils.getColorFromHex(str);
      if (localInteger != null)
      {
        LOG.logDebug(TAG, "Setting {0} background color to a web view", new Object[] { str });
        paramWebView.setBackgroundColor(localInteger.intValue());
      }
    }
  }

  public void createImplementation(IFactoryCallback paramIFactoryCallback, boolean paramBoolean)
  {
    Utils.checkNotNull(paramIFactoryCallback, "factory callback must not be null");
    this.mCreateForFullscreen = paramBoolean;
    doCreate(paramIFactoryCallback);
  }

  static abstract interface IFactoryCallback
  {
    public abstract void defaultViewCreated(UiSafeWebView paramUiSafeWebView);

    public abstract void mraidViewCreated(MraidView paramMraidView);

    public abstract void ormmaViewCreated(OrmmaView paramOrmmaView);

    public abstract void rewardsViewCreated(RewardsView paramRewardsView);
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.lib.component.networkcomponent.burstly.html.WebViewFactory
 * JD-Core Version:    0.6.2
 */